#include <iostream>
using namespace std;
#include <cstring>
int myadd(int num1, int num2)
{
    return num1 + num2;
}

float myadd(float num1, float num2)
{
    return num1 + num2;
}

class Point
{
public:
    Point() : Point(0, 0)
    {
    }
    Point(int x, int y) : m_x(x), m_y(y) {}

public:
    Point operator+(const Point &point);
    friend ostream &operator<<(ostream &cout, const Point &p);

public:
    int m_x;
    int m_y;
};

Point myadd(Point p1, Point p2)
{
    return p1 + p2;
}

Point Point::operator+(const Point &point)
{
    Point res(0, 0);
    res.m_x = this->m_x + point.m_x;
    res.m_y = this->m_y + point.m_y;
    return res;
}

ostream &operator<<(ostream &cout, const Point &p)
{
    cout << "(" << p.m_x << ", " << p.m_y << ")";
    return cout;
}

template <class T>
T myadd(T num1, T num2)
{
    return num1 + num2;
}
template <typename Item>
class MyVector
{
public:
    template <typename I>
    friend ostream &operator<<(ostream &cout, const MyVector<I> &vec);

public:
    MyVector() : MyVector(10) // 无参构造
    {
    }
    MyVector(int capacity) // 有参构造
    {
        m_size = 0;
        m_capacity = capacity;
        m_data = new Item[m_capacity];
        memset(m_data, 0, sizeof(Item) * m_capacity);
    }

public:
    void insertData(const Item data) // 插入数据
    {
        m_data[m_size++] = data;
    }

public:
    Item operator[](int index) // 重载[]
    {
        if (index < 0 || index > m_size - 1)
        {
            cout << "error" << endl;
            //todo......
        }
        return m_data[index];
    }

private:
    int m_size;     // 元素个数
    int m_capacity; // 容量
    Item *m_data;   // 数据本身
};
template <typename I>
ostream &operator<<(ostream &cout, const MyVector<I> &vec)
{
    cout << "[ ";
    for (int idx = 0; idx < vec.m_size; idx++)
    {
        cout << vec.m_data[idx];
    }
    cout << "]";
    return cout;
}

int main()
{
#if 0
    int val1 = 100;
    int val2 = 200;
    cout << myadd(val1, val2) << endl;

    float num1 = 100.3;
    float num2 = 200.4;
    cout << myadd(num1, num2) << endl;

    Point p1(3, 2);
    Point p2(4, 3);
    cout << myadd(p1, p2).m_x<<","<<myadd(p1, p2).m_y << endl;
#endif

#if 1
    MyVector<Point> myVec;
    Point p1(1, 2);
    Point p2(3, 4);
    Point p3(5, 6);
    myVec.insertData(p1);
    myVec.insertData(p2);
    myVec.insertData(p3);

    cout << myVec[1] << endl;

#endif
}
